﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Reflection;

namespace Baubixinh_client
{
    public partial class frmExportFilter : DevExpress.XtraEditors.XtraForm
    {
        public bool FilterSelected { get; set; }

        public int StoreID { get; set; }
        public int StaffID { get; set; }
        public DateTime DateFrom { get; set; }
        public DateTime DateTo { get; set; }

        public frmExportFilter()
        {
            InitializeComponent();
        }

        private void frmExportFilter_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable objStore;

                objStore = clsDbAccess.fncGetAttributeValue(Program.gobjDb, clsEnum.ATTRIBUTE.STORE);

                txtStore.Properties.DataSource = objStore;
                

                txtStore.Focus();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.FilterSelected = false;
            this.Close();
        }

        private void btnChon_Click(object sender, EventArgs e)
        {
            try
            {
                if (!objValidation.Validate()) return;

                this.StoreID = clsCommon.fncCnvNullToInt(txtStore.EditValue);
                this.StaffID = clsCommon.fncCnvNullToInt(txtSeller.EditValue);
                this.DateFrom = clsCommon.fncCnvNullToDatetime(txtDateFrom.EditValue);
                this.DateTo = clsCommon.fncCnvNullToDatetime(txtDateTo.EditValue);
                this.FilterSelected = true;

                this.Close();
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }

        private void txtStore_EditValueChanged(object sender, EventArgs e)
        {
            try
            {
                //load nhan vien
                int intStore = clsCommon.fncCnvNullToInt(txtStore.EditValue);
                DataTable objSeller = clsDbAccess.fncGetAttributeValue(Program.gobjDb, clsEnum.ATTRIBUTE.STAFF, intStore);
                txtSeller.Properties.DataSource = objSeller;
            }
            catch (Exception ex) { clsCommon.fncMsgError(MethodBase.GetCurrentMethod().ReflectedType.Name, MethodBase.GetCurrentMethod().Name, ex.Message); }
        }
    }
}